package com.yun.algorithmproblem.leetcode;

public class Leetcode122_SharesII {
    public int maxProfit(int[] prices) {
        int i = 0;
        int j = 1;
        int profit=0;
        while (j < prices.length) {
            if (prices[j] - prices[i] > 0) {
                profit+=prices[j]-prices[i];
            }
            i++;
            j++;
        }
        return profit;
    }
}
